package com.lu.adog.demo.common;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lu.adog.R;
import com.lu.adog.base.BaseFragment;
import com.lu.adog.view.MultiItemDivider;

/**
 * Created by Yue on 2017/11/18.
 */

public abstract class CommonListFragment extends BaseFragment {
    private void assignViews(View view) {
        RecyclerView rvContentList = (RecyclerView) view.findViewById(R.id.rv_contentList_main);
        rvContentList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        MultiItemDivider multiItemDivider = new MultiItemDivider(getContext(), MultiItemDivider.VERTICAL_LIST);
        multiItemDivider.setDividerMode(MultiItemDivider.END);
        rvContentList.addItemDecoration(multiItemDivider);

        bindCommonItemAdapter(rvContentList);
    }
    protected abstract void bindCommonItemAdapter(RecyclerView rvContentList);

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        RecyclerView recyclerView = new RecyclerView(getContext());
        View view = inflater.inflate(R.layout.layout_commonlist,container,false);
        assignViews(view);
        return view;

    }

}
